package core;

/**
 * 
 *
 */
public enum KeyWord {
	
	MAIN("main"),
	TRUE("true"),
	FALSE("false"),
	IF("if"),
	ELSE("else"),
	NULL("null"),
	RETURN("return"),
	VOID("void"),
	BOOLEAN("boolean"),
	STRING("string"),
	INT("int"),
	CHAR("char"),
	WRITE("write"),
	WHILE("while"),
	READ("read"),
	PUTCHAR("putchar"),
	GETCHAR("getchar"),
	ARRAYOF("arrayof"), 
	METHOD("method"), CALL("call");

	/**
	 * The token
	 */
	private String token;
	
	/**
	 * Constructs a KeyWord using the given token.
	 * @param token the token
	 */
	private KeyWord( String token ) {
		this.token = token;
	}
	
	/**
	 * Verifies if the given KeyWord is equal to this.
	 * @param other the given KeyWord.
	 * @return true if the KeyWord is equal to this, otherwise false.
	 */
	public boolean equals( KeyWord other ){
		return token.equals(other.token);
	}
	
	/**
	 * Verifies if the given token is equal to this <code>KeyWord</code>.
	 * @param other the given token
	 * @return true if the token is equal to the <code>KeyWord</code>, otherwise false.
	 */
	public boolean hasSameToken( String other ){
		return token.equalsIgnoreCase( other );
	}

	/**
	 * Returns the token
	 * @return the token
	 */
	public String getToken() {
		return token;
	}
	
}
